<template>
  <van-date-picker
    v-model="currentDate"
    title="选择日期"
    :min-date="minDate"
    :max-date="maxDate"
    @confirm="onConfirm" />
</template>

<script>
import { defineComponent} from "vue";
export default defineComponent({
  name: "zheng-date-picker",
  props: {
    currentDate: {
      type: String,
      default: "2018-01-01"
    }
  },

  setup(props,{ emit }) {
    console.log(props)
    const currentDate = props.currentDate ? props.currentDate.split("-") : "2018-01-01".split("-");
    const columnsType = ['year', 'month', 'day'];
    const onConfirm = (value)=>{
      emit('date-confirm-click', value.selectedValues.join(",").replace(/,/g,"-"))
    }
    return {
      columnsType,
      currentDate,
      minDate: new Date(1949, 0, 1),
      maxDate: new Date(2025, 5, 1),
      onConfirm
    };
  },

});
</script>
